<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Amaze UI Admin form Examples</title>
<meta name="description" content="这是一个form页面">
<meta name="keywords" content="form">
<% include("/common/inc/_css.html"){} %>
</head>
<body>
	<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

	<% include("/common/inc/_header.html"){} %>

	<div class="am-cf admin-main">
		<!-- sidebar start -->
		<% include("/common/inc/_menu.html"){} %>
		<!-- sidebar end -->

		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				<div class="am-cf am-padding am-padding-bottom-0">
					<div class="am-fl am-cf">
						<strong class="am-text-primary am-text-lg">表单</strong> / <small>form</small>
					</div>
				</div>

				<hr>

				<form class="am-form" method="post" id="doc-vld-msg">
				<fieldset>
					<div class="am-g am-margin-top-sm">
						<div class="am-u-sm-4 am-u-md-2 am-text-right">菜单编码</div>
						<div class="am-u-sm-8 am-u-md-4 am-u-end">
							<input type="text" name="func_code" id="doc-vld-name" minlength="2" placeholder="不少於兩位" class="am-input-sm" required/>
						</div>
					</div>

					<div class="am-g am-margin-top">
						<div class="am-u-sm-4 am-u-md-2 am-text-right">菜单名字</div>
						<div class="am-u-sm-8 am-u-md-4">
							<input type="text" name="func_name" id="doc-vld-name" minlength="2" placeholder="不少於兩位" class="am-input-sm" required/>
						</div>
						<div class="am-hide-sm-only am-u-md-6"></div>
					</div>

					 <div class="am-g am-margin-top">
				      <div class="am-u-sm-4 am-u-md-2 am-text-right">菜单类型</div>
										<div class="am-u-sm-8 am-u-md-4">
				      <select data-am-selected="{btnSize: 'sm'}" id="doc-select-1" name="func_type" required>
				        <option value="">请选择一项</option>
				        <option value="1">菜单</option>
				        <option value="2">文件夹</option>
				      </select>   
				    </div>
				    <div class="am-hide-sm-only am-u-md-6"></div>
					</div>	
					
				 	<div class="am-g am-margin-top-sm">
						<div class="am-u-sm-4 am-u-md-2 am-text-right">访问地址</div>
						<div class="am-u-sm-8 am-u-md-4 am-u-end">
							<input type="text" name="func_url" id="doc-vld-name" minlength="2" placeholder="不少於兩位" class="am-input-sm" required/>
						</div>
					</div>
				 
				 
				 
				 		<div class="am-g am-margin-top">
						<div class="am-u-sm-4 am-u-md-2 am-text-right">上级菜单</div>
						<div class="am-u-sm-8 am-u-md-4">
							<input type="text" name="parent_id" class="am-input-sm">
						</div>
						<div class="am-hide-sm-only am-u-md-6"></div>
					</div>
				 
				
						<div class="am-margin">
						<button id="btnTypeSave" type="submit" class="am-btn am-btn-primary am-btn-xs btn-loading-example" 
		             	data-am-loading="{spinner: 'circle-o-notch', loadingText: '提交中...', resetText: '提交保存'}">
		             	立即提交</button>
						<button type="button" class="am-btn am-btn-primary am-btn-xs">放弃保存</button>
					</div>
					</fieldset>
				</form>


			</div>
			<footer class="admin-content-footer">
				<hr>
				<p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed
					under MIT license.</p>
			</footer>
		</div>
		<!-- content end -->

	</div>

	<a href="#"
		class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"></a>

	<footer>
		<hr>
		<p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under
			MIT license.</p>
	</footer>

	<% include("/common/inc/_js.html"){} %>
	<!-- ajax提交表单 -->
	<script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.min.js"></script>
	<script type="text/javascript">
	$(function() {
		$("#btnTypeSave").click(function() {
			var isFormValid = $('#doc-vld-msg').validator('isFormValid');
			if (!isFormValid){
				$btn.removeClass("am-disabled");
				return;
			}

			var $a = $(this);
			$a.addClass("am-disabled"); 
			$(".am-form").ajaxSubmit({
				success : function(data) {
					$a.removeClass("am-disabled"); 
					
					if (data.errorCode != "0") {
						console.log(data.errorMsg);
						return;
						//alert(data.errorMsg);
						
					}
					 //跳转页面
					window.location.href="${ctxPath}/auth/function/list"; 
				}
			})
			return false;
		})
});


	</script>
	<script type="text/javascript">
$('.btn-loading-example').click(function () {
	  var $btn = $(this)
	  $btn.button('loading');
	    setTimeout(function(){
	      $btn.button('reset');
	  }, 1000);
	});
</script>
</body>
</html>
